package com.wushi.smartorm;

/**
 * 通过ThreadLocal容器可以为每个线程缓存executor
 *
 * @program: smartorm
 * @description:
 * @author: Grant Wu
 * @create: 2020-05-19 22:34
 **/

public class OrmExecutorFactory {
    private static ThreadLocal<OrmExecutor> executors=new ThreadLocal<>();

    public static OrmExecutor getExecutor() {
        OrmExecutor ormExecutor = executors.get();
        if(ormExecutor==null){
            ormExecutor = new OrmExecutor();
            setExecutor(ormExecutor);
        }
        return ormExecutor;
    }

    public static void setExecutor( OrmExecutor ormExecutor){
        executors.set(ormExecutor);
    }
}
